#include <iostream>
#include "includes/time-step.hh"
// #define DEBUG_TIMESTEP
TimeStep::TimeStep(){
};
TimeStep::~TimeStep(){
};
void TimeStep::get_dt(SubprojectBase* subproject, double pillarlen, int i){
  double local_dt=0;
  subproject->equation->get_local_vmax(i);
  if(memory::dgflag==0){
    switch(setting::spacediscrete){
    case setting::lf:
    case setting::upwind:
    case setting::lw:
      local_dt=timerule::cfl*pillarlen/memory::local_vmax[i]/gridsetting::dimension;
      break;
    case setting::tvdlf:
      local_dt=timerule::cfl*pillarlen/memory::local_vmax[i]/gridsetting::dimension;
    }
  }
  if(memory::dgflag==1){
    switch(setting::spacediscrete){
    case setting::lf:
    case setting::upwind:
    case setting::lw:
      // local_dt=timerule::cfl*pillarlen/memory::local_vmax[i]/gridsetting::dimension*3; ///(2*memory::dgorder+1);
      local_dt=timerule::cfl*pillarlen/memory::local_vmax[i]/gridsetting::dimension;///(2*memory::dgorder-1);      
      break;
    case setting::tvdlf:
      local_dt=timerule::cfl*pillarlen/memory::local_vmax[i]/gridsetting::dimension*1.0;//(2*memory::dgorder+1)*6.0;
    }
  }
  global_dt=std::min(global_dt,local_dt);
#ifdef DEBUG_TIMESTEP
      std::cout << "global_dt: " << global_dt << std::endl;
#endif
};
